package view.component.sider
{
import flash.display.DisplayObject;
import flash.display.MovieClip;

import framework.proxy.ComponentProxy;
import view.component.sider.SiderItemUIElementProxy;

/**
 * SiderUIProxy
 * @author jliang
 * 
 */
public class SiderUIProxy extends ComponentProxy
{
	//==========================================================================
	//  Constructor
	//==========================================================================
	public function SiderUIProxy()
	{
		super();
	}
    /*
	//==========================================================================
	//  Variables
	//==========================================================================
	private var proxys:Vector.<SiderItemUIElementProxy> = new Vector.<SiderItemUIElementProxy>();
	private var waitingQueen:Vector.<Object> = new Vector.<Object>();
	
	private function get currentCount():int
	{
		var count:int = 0;
		for each (var proxy:SiderItemUIElementProxy in proxys)
		{
			if (proxy.isWorking)
			{
				count ++;
			}
		}
		return count;
	}
	//==========================================================================
	//  Overridden methods: ComponentProxy
	//==========================================================================
	override public function parse(target:MovieClip):void
	{
		super.parse(target);
		
		for (var i:int = 0; i < skin.numChildren; i++)
		{
			var render:DisplayObject = skin.getChildAt(i);
			var proxy:SiderItemUIElementProxy = new SiderItemUIElementProxy();
			proxy.parse(render as MovieClip);
			
			var index:int = render.name.split("_render_")[1];
			proxys[index] = proxy;
		}
	}
    */
	//==========================================================================
	//  Public methods
	//==========================================================================
	public function addElement(id:String, displayObj:DisplayObject, data:Object, clickCallBack:Function, mouseOverCallBack:Function=null, mouseOutCallBack:Function=null):void
	{
        /*
		var temp:Vector.<Object> = new Vector.<Object>();
		temp.push({id:id, displayObj:displayObj, data:data, clickCallBack:clickCallBack, mouseOverCallBack:mouseOverCallBack, mouseOutCallBack:mouseOutCallBack});
		waitingQueen = temp.concat(waitingQueen);
		
		var count:int = currentCount;
		if (count == proxys.length)
		{
			removeElementByIndex(proxys.length - 1);
		}
		else
		{
			removeElementByIndex(count);
		}
		
		var obj:Object = waitingQueen.splice(0, 1)[0];
		updateElement(proxys[0], obj.id, obj.displayObj, obj.data, obj.clickCallBack, obj.mouseOverCallBack, obj.mouseOutCallBack);
        */
	}
	
	public function removeElement(id:String):void
	{
        /*
		for (var i:int = 0; i < proxys.length; i++)
		{			
			if (proxys[i].id == id)
			{
				removeElementByIndex(i);
				return;
			}
		}
        */
	}
	
	private function updateElement(proxy:SiderItemUIElementProxy, id:String, displayObj:DisplayObject, data:Object, clickCallBack:Function, mouseOverCallBack:Function, mouseOutCallBack:Function):void
	{
        /*
		proxy.remove();
		proxy.id = id;
		proxy.data = data;
		proxy.clickCallBack = clickCallBack;
		proxy.mouseOverCallBack = mouseOverCallBack;
		proxy.mouseOutCallBack = mouseOutCallBack;
		proxy.add(displayObj);
        */
	}
	
	private function removeElementByIndex(index:int):void
	{
        /*
		proxys[index].remove();
		var i:int;
		if (waitingQueen.length > 0)
		{
			if (index == 0)
			{
				return;
			}
			for (i = index - 1; i >= 0; i--)
			{
				updateElement(proxys[i + 1], proxys[i].id, proxys[i].content, proxys[i].data, proxys[i].clickCallBack, proxys[i].mouseOverCallBack, proxys[i].mouseOutCallBack);
				proxys[i].remove();
			}
		}
		else
		{
			var next:int = index + 1;
			if (next > proxys.length - 1)
			{
				return;
			}
			for (i = next; i < proxys.length; i++)
			{
				if (!proxys[i].isWorking) return;
				updateElement(proxys[i - 1], proxys[i].id, proxys[i].content, proxys[i].data, proxys[i].clickCallBack, proxys[i].mouseOverCallBack, proxys[i].mouseOutCallBack);
			}
		}
        */
	}
}
}


